package com.ruoyi.cms.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.cms.mapper.CmsTopicMapper;
import com.ruoyi.cms.domain.CmsTopic;
import com.ruoyi.cms.service.ICmsTopicService;
import com.ruoyi.common.core.text.Convert;

/**
 * 内容信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-07-30
 */
@Service
public class CmsTopicServiceImpl implements ICmsTopicService 
{
    @Autowired
    private CmsTopicMapper cmsTopicMapper;

    /**
     * 查询内容信息
     * 
     * @param topicId 内容信息ID
     * @return 内容信息
     */
    @Override
    public CmsTopic selectCmsTopicById(Long topicId)
    {
        return cmsTopicMapper.selectCmsTopicById(topicId);
    }

    /**
     * 查询内容信息列表
     * 
     * @param cmsTopic 内容信息
     * @return 内容信息
     */
    @Override
    public List<CmsTopic> selectCmsTopicList(CmsTopic cmsTopic)
    {
        return cmsTopicMapper.selectCmsTopicList(cmsTopic);
    }

    /**
     * 新增内容信息
     * 
     * @param cmsTopic 内容信息
     * @return 结果
     */
    @Override
    public int insertCmsTopic(CmsTopic cmsTopic)
    {
        cmsTopic.setStatus("0");
        cmsTopic.setDelFlag("0");
        cmsTopic.setCreateTime(DateUtils.getNowDate());
        return cmsTopicMapper.insertCmsTopic(cmsTopic);
    }

    /**
     * 修改内容信息
     * 
     * @param cmsTopic 内容信息
     * @return 结果
     */
    @Override
    public int updateCmsTopic(CmsTopic cmsTopic)
    {
        cmsTopic.setDelFlag(null);
        cmsTopic.setUpdateTime(DateUtils.getNowDate());
        return cmsTopicMapper.updateCmsTopic(cmsTopic);
    }

    /**
     * 删除内容信息对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteCmsTopicByIds(String ids)
    {
        return cmsTopicMapper.deleteCmsTopicByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除内容信息信息
     * 
     * @param topicId 内容信息ID
     * @return 结果
     */
    @Override
    public int deleteCmsTopicById(Long topicId)
    {
        return cmsTopicMapper.deleteCmsTopicById(topicId);
    }
}
